//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.二分查找;

import java.util.Arrays;

public class demo_1385 {
    public demo_1385() {
    }

    public static void main(String[] args) {
        int[] arr1 = new int[]{1, 4, 2, 3};
        int[] arr2 = new int[]{-4, -3, 6, 10, 20, 30};
        System.out.println(findTheDistanceValue(arr1, arr2, 3));
    }

    public static int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
        Arrays.sort(arr1);
        Arrays.sort(arr2);
        int ans = 0;
        int j = 0;
        int[] var5 = arr1;
        int var6 = arr1.length;

        for(int var7 = 0; var7 < var6; ++var7) {
            int x;
            for(x = var5[var7]; j < arr2.length && arr2[j] < x - d; ++j) {
            }

            if (j == arr2.length || arr2[j] > x + d) {
                ++ans;
            }
        }

        return ans;
    }
}
